import { createAPI } from '@/api/http';
import { Opts } from '@/api/opts';

/**
 *  @description 添加角色
 *  @name createRole
 *  @param  name 角色名 {string} 必传参数
 *  @param  sole 角色唯一标识 {string} 必传参数
 *  @param  memo 备注 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const createRole = (opts: Opts) =>
  createAPI({
    method: 'post',
    url: '/wit/role/createRole',
    opts,
  });

/**
 *  @description 删除角色
 *  @name deleteRole
 *  @param  id role id {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const deleteRole = (opts: Opts) =>
  createAPI({
    method: 'delete',
    url: '/wit/role/deleteRole',
    opts,
  });

/**
 *  @description 通过id获取角色信息
 *  @name getRoleById
 *  @param  id role id {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getRoleById = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/role/getRoleById',
    opts,
  });

/**
 *  @description 获取角色信息
 *  @name getRoleList
 *  @param  pageNum 页码 {integer} 
 *  @param  pageSize 每页数 {integer} 
 *  @param  name 角色名 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getRoleList = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/role/getRoleList',
    opts,
  });

/**
 *  @description 修改角色
 *  @name updateRole
 *  @param  id ID {string} 必传参数
 *  @param  name 角色名 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const updateRole = (opts: Opts) =>
  createAPI({
    method: 'put',
    url: '/wit/role/updateRole',
    opts,
  });
